Skip to content

Refactor to Support SRD 5.1 and SRD 5.2 Rulesets#1

Closed
google-labs-jules[bot] wants to merge 2 commits intomainfrom
feat/srd-ruleset-refactor
Closed

Refactor to Support SRD 5.1 and SRD 5.2 Rulesets#1
google-labs-jules[bot] wants to merge 2 commits intomainfrom
feat/srd-ruleset-refactor

Conversation

@google-labs-jules
Copy link

This refactoring enables the application to support both SRD 5.1 and SRD 5.2 rulesets for D&D characters. It introduces a ruleset attribute to the character data model, separates the rules-specific data into distinct files for each version, and updates the character computation services to dynamically load and apply the correct ruleset based on the character's data. This makes the system more flexible and extensible for future ruleset additions.


PR created automatically by Jules for task 17671055234094048508

This refactors the D&D character management to support both SRD 5.1 and SRD 5.2 rulesets.

- Adds a `ruleset` field to the `Character` schema and a corresponding database migration.
- Splits the D&D data into `srd51.ts` and `srd52.ts` files.
- Refactors `src/lib/dnd.ts` to be a core rules file with a `getRuleset` function to dynamically load the correct ruleset.
- Updates character computation and services to be ruleset-aware, using the dynamically loaded ruleset data.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

Comment on lines +2 to +21
import type {
AbilityScoreModifiers,
AbilityType,
Background,
BackgroundFeature,
BackgroundNameType,
CasterKindType,
Choice,
ClassDef,
ClassNameType,
HitDieType,
Race,
SizeType,
SkillType,
SlotProgression,
SpellSlotsType,
Subrace,
SpellcastingInfo,
SpellChangeEventType
} from "../dnd";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of unused imports here and in other files; can you clean up unused imports?

Comment on lines +29 to +60
const ArtisanTools = [
"alchemist’s supplies",
"brewer’s supplies",
"calligrapher’s supplies",
"carpenter’s tools",
"cartographer’s tools",
"cobbler’s tools",
"cook’s utensils",
"glassblower’s tools",
"jeweler’s tools",
"leatherworker’s tools",
"mason’s tools",
"painter’s supplies",
"potter’s tools",
"smith’s tools",
"tinker’s tools",
"weaver’s tools",
"woodcarver’s tools",
] as const;

const Instruments = [
"bagpipes",
"drum",
"dulcimer",
"flute",
"lute",
"lyre",
"horn",
"pan flute",
"shawm",
"viol",
] as const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem unused?

Comment on lines +787 to +789
Races,
RaceNames,
SubraceNames,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets stick with consistent terminology and just go with 'species' and 'lineage' in both rulesets.

// =====================
// Data (Player’s Handbook classes, lowercase)
// =====================
export const Classes: Record<ClassNameType, ClassDef> = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is removed, but still imported in, e.g. addLevel service. please double-check all places that depend on removed imports from this file, and convert them to use rulesets

Comment on lines +527 to +546
{level: 1, cantrips: 3, prepared: 4, slots: [2, 0, 0, 0, 0, 0, 0, 0, 0]},
{level: 2, cantrips: 3, prepared: 5, slots: [3, 0, 0, 0, 0, 0, 0, 0, 0]},
{level: 3, cantrips: 3, prepared: 6, slots: [4, 2, 0, 0, 0, 0, 0, 0, 0]},
{level: 4, cantrips: 4, prepared: 7, slots: [4, 3, 0, 0, 0, 0, 0, 0, 0]},
{level: 5, cantrips: 4, prepared: 9, slots: [4, 3, 2, 0, 0, 0, 0, 0, 0]},
{level: 6, cantrips: 4, prepared: 10, slots: [4, 3, 3, 0, 0, 0, 0, 0, 0]},
{level: 7, cantrips: 4, prepared: 11, slots: [4, 3, 3, 1, 0, 0, 0, 0, 0]},
{level: 8, cantrips: 4, prepared: 12, slots: [4, 3, 3, 2, 0, 0, 0, 0, 0]},
{level: 9, cantrips: 4, prepared: 14, slots: [4, 3, 3, 3, 1, 0, 0, 0, 0]},
{level: 10, cantrips: 5, prepared: 15, slots: [4, 3, 3, 3, 2, 0, 0, 0, 0]},
{level: 11, cantrips: 5, prepared: 16, slots: [4, 3, 3, 3, 2, 1, 0, 0, 0]},
{level: 12, cantrips: 5, prepared: 16, slots: [4, 3, 3, 3, 2, 1, 0, 0, 0]},
{level: 13, cantrips: 5, prepared: 17, slots: [4, 3, 3, 3, 2, 1, 1, 0, 0]},
{level: 14, cantrips: 5, prepared: 17, slots: [4, 3, 3, 3, 2, 1, 1, 0, 0]},
{level: 15, cantrips: 5, prepared: 18, slots: [4, 3, 3, 3, 2, 1, 1, 1, 0]},
{level: 16, cantrips: 5, prepared: 18, slots: [4, 3, 3, 3, 2, 1, 1, 1, 0]},
{level: 17, cantrips: 5, prepared: 19, slots: [4, 3, 3, 3, 2, 1, 1, 1, 1]},
{level: 18, cantrips: 5, prepared: 20, slots: [4, 3, 3, 3, 3, 1, 1, 1, 1]},
{level: 19, cantrips: 5, prepared: 21, slots: [4, 3, 3, 3, 3, 2, 1, 1, 1]},
{level: 20, cantrips: 5, prepared: 22, slots: [4, 3, 3, 3, 3, 2, 2, 1, 1]},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the srd51 rules don't list a number of prepared spells by level. instead, the rules say "You
 prepare
 the
 list
 of
 cleric
 spells
 that
 are
 
available
 for
 you
 to
 cast,
 choosing
 from
 the
 cleric
 
spell
 list.
 When
 you
 do
 so,
 choose
 a
 number
 of
 cleric
 
spells
 equal
 to
 your
 Wisdom
 modifier
 +
 your
 cleric
 
level
 (minimum
 of
 one
 spell).
 The
 spells
 must
 be
 of
 a
 
level
 for
 which
 you
 have
 spell
 slots." this is true for other prepared spellcasters as well, e.g. druid, or for paladin it says "When
 you
 do
 so,
 choose
 a
 number
 of
 
paladin
 spells
 equal
 to
 your
 Charisma
 modifier
 +
 half
 
your
 paladin
 level,
 rounded
 down
 (minimum
 of
 one
 
spell)." can you double-check all of these and correct them?

"acolyte", "criminal", "sage", "soldier"
] as const;

const Backgrounds: Record<BackgroundNameType, Background> = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have all backgrounds here. we might need to move BackgroundNameType to the rulesets as well, since this is an invalid type.

This refactors the D&D character management to support both SRD 5.1 and SRD 5.2 rulesets.

- Adds a `ruleset` field to the `Character` schema and a corresponding database migration.
- Splits the D&D data into `srd51.ts` and `srd52.ts` files.
- Refactors `src/lib/dnd.ts` to be a core rules file with a `getRuleset` function to dynamically load the correct ruleset.
- Updates character computation and services to be ruleset-aware, using the dynamically loaded ruleset data.
- Corrects spell preparation calculations for SRD 5.1 and cleans up unused imports and data inconsistencies.
@igor47 igor47 closed this Oct 15, 2025
@igor47 igor47 deleted the feat/srd-ruleset-refactor branch October 15, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant